<?php
namespace Home\Controller;

class SupportController extends HomeController {

    public function index(){

        $cateID = I('get.cateID');
        
        if ($cateID=='' || !is_numeric($cateID)) {
            $this->error('Parameter error');            
        }

        $cate = M('Category')->where(array('id'=>$cateID))->find();
        if (!$cate) {
            $this->error('Classification does not exist');
        }

        $map['del'] = 0;
        $map['cid'] = $cateID;
        $map['status'] = 1;
        $obj = M('Article');
        $count = $obj->where($map)->count();
        import("Common.ORG.BootstrapPage");
        $page = new \Page($count, 10);
        $show = $page->show();
        $list = $obj->where($map)->order('createTime desc,id desc')->limit($page->firstRow . ',' . $page->listRows)->select();
        $this->assign('list',$list);
        $this->assign('page',$show);
        $this->assign('cate',$cate);
        $this->assign('cateID',$cateID);
        $this->display();

    }

    public function detail(){
        $id = I('get.id');
        if ($id=='' || !is_numeric($id)) {
            $this->error('Parameter error');
        }

        $map['id'] = $id;
        $map['status'] = 1;
        $map['del'] = 0;        
        $list = M('Article')->where($map)->find();
        if (!$list) {
            $this->error('文章不存在');
        }else{
            M('Article')->where($map)->setInc('hit');

            $this->assign('list', $list);
            
            $this->display();
        }
    }

}